package com.gwt.dispatcher.dispatcher.server;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gwt.dispatcher.dispatcher.shared.Action;
import com.gwt.dispatcher.dispatcher.shared.Result;
import com.gwt.dispatcher.dispatcher.shared.exceptions.DispatchException;

/**
 * 
 * This is the abstract class that should be extended to provide the needed
 * Handler on a particular Action, ie:
 * 
 * <p>
 * 
 * <pre>
 * 
 * public class GetCircuitInfoHandler extends ActionHandler<GetCircuitInfoSimple, CircuitInfo> {
 *
 *	public CircuitInfo execute(GetCircuitInfoSimple action) throws SNMException {
 *	  ...
 *  }
 * 
 * </pre>
 * 
 * </p>
 * 
 * @author cristian.n.miranda
 *
 */
public abstract class ActionHandler<A extends Action<T>, T extends Result> {
    private HttpServletRequest threadLocalRequest; 
    private HttpServletResponse threadLocalResponse;

    public abstract T execute(A action) throws DispatchException;
	
	public HttpServletRequest getThreadLocalRequest() {
		return threadLocalRequest;
	}
	public void setThreadLocalRequest(HttpServletRequest threadLocalRequest) {
		this.threadLocalRequest = threadLocalRequest;
	}
	public HttpServletResponse getThreadLocalResponse() {
		return threadLocalResponse;
	}
	public void setThreadLocalResponse(HttpServletResponse threadLocalResponse) {
		this.threadLocalResponse = threadLocalResponse;
	}
	
}
